<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>暂停设备中</title>
    <link rel="stylesheet" href="/static/css/weui.css" />
    <link rel="stylesheet" href="/static/css/example.css" />
</head>

<body ontouchstart>
    <script type="text/html" id="tpl_home">
    <div class='page'>
        <div id="loadingToast" style="opacity: 0; display: none;">
            <div class="weui-mask_transparent">
            </div>
            <div class="weui-toast">
                <i class="weui-loading weui-icon_toast"></i>
                <p class="weui-toast__content" id="flag">暂停设备动作</p>
            </div>
        </div>
    </div>
    
            <script src="/static/js/jquery.min.js"></script>
            <script src="/static/js/weui.min.js"></script>
            <script type="text/javascript" src="/static/js/jweixin-1.4.0.js"></script>         
            <script src="/static/js/zepto.min.js"></script>
            <script src="/static/js/example.js"></script>
            <!-- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>-->  
            
            
            <script type="text/javascript">
                $(function() {

                    function getQueryString(name) {
                        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                        var r = decodeURI(window.location.search).substr(1).match(reg);
                        if (r != null) return (r[2]);
                        return null;
                    };

                    $(document).ready(function() {
                        var code = getQueryString('code');
                        var carbinId = getQueryString('carbinId');
                        var commuName = getQueryString('commuName');
                        var commuAdd = getQueryString('commuAdd');
                        var usedVol = getQueryString('usedVol');
                        var maxVol = getQueryString('maxVol');
                        var status = getQueryString('status');
                        var area = getQueryString('area');

                        var $loadingToast = $('#loadingToast');
                        $loadingToast.fadeIn(100);
                        setTimeout(function () {
                            $loadingToast.fadeOut(100);
                        }, 2000);

                        // 根据deviceid和code 获取设备情况
                        $.ajax({
                            url: 'http://gzh.zjnnhj.com/niuneng/stopCmd',
                            type: "post",
                            data: JSON.stringify({
                                "code": code,
                                "deviceid": carbinId
                            }),
                            dataType: "json",
                            success: function(res) {
                                var fredirect_uri = 'http://gzh.zjnnhj.com/niuneng/operate.html?carbinId=' + carbinId + '&commuName=' + commuName + '&commuAdd=' + commuAdd + '&usedVol=' + usedVol + '&maxVol=' + maxVol + '&status=' + status + '&area=' + area;
                                var ffurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5f2850581e4e064d&redirect_uri=" + encodeURIComponent(fredirect_uri) + "&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
                                location.href = ffurl;
                            
                            }            
                    })
                })
            })

            </script>

    </script>
</body>

</html>